﻿using Project_Maverick.Content.Images.Background;
using Transformable_Engine_v2.Engine.GameObjects.Containers;
using Transformable_Engine_v2.Engine.GameObjects.Containers.Transformable_controls;
using Transformable_Engine_v2.Engine.Graphics;
using Transformable_Engine_v2.Engine.Transformable_Math.Geometry;

namespace Project_Maverick.Screen.Common
{
    public class StitchBackground : Container
    {
         public StitchBackground(TE_Vector2 size)
         {
             Container stitchContainer = new Container(-size / 2);

             stitchContainer.AddChildren(new ImageContainer
                                             {
                                                 PositionGridBound = new TE_Vector2(0, 0),
                                                 Sprite = SpriteSheetBackground.GetSprite(SpriteSheetBackground.StitchBackground.TopLeft)
                                             });
             stitchContainer.AddChildren(new ImageContainer
             {
                 PositionGridBound = new TE_Vector2(size.X, 0),
                 Sprite = SpriteSheetBackground.GetSprite(SpriteSheetBackground.StitchBackground.TopRight),
                 Origin = TE_Rectangle.Alignment.TopRight,
             });
             stitchContainer.AddChildren(new ImageContainer
             {
                 PositionGridBound = new TE_Vector2(0, size.Y),
                 Sprite = SpriteSheetBackground.GetSprite(SpriteSheetBackground.StitchBackground.BottomLeft),
                 Origin = TE_Rectangle.Alignment.BottomLeft
             });
             stitchContainer.AddChildren(new ImageContainer
             {
                 PositionGridBound = new TE_Vector2(size.X, size.Y),
                 Sprite = SpriteSheetBackground.GetSprite(SpriteSheetBackground.StitchBackground.BottomRight),
                 Origin = TE_Rectangle.Alignment.BottomRight
             });

             stitchContainer.AddChildren(new RepeatingImage
                                             {
                                                 PositionGridBound = new TE_Vector2(6, 0),
                                                 Sprite = SpriteSheetBackground.GetSprite(SpriteSheetBackground.StitchBackground.TopMiddle),
                                                 AreaRectangle = new TE_Rectangle(0, 0, size.X - 12, 6)
                                             });

             stitchContainer.AddChildren(new RepeatingImage
             {
                 PositionGridBound = new TE_Vector2(6, size.Y - 6),
                 Sprite = SpriteSheetBackground.GetSprite(SpriteSheetBackground.StitchBackground.BottomMiddle),
                 AreaRectangle = new TE_Rectangle(0, 0, size.X - 12, 6)
             });

             stitchContainer.AddChildren(new RepeatingImage
             {
                 PositionGridBound = new TE_Vector2(0, 6),
                 Sprite = SpriteSheetBackground.GetSprite(SpriteSheetBackground.StitchBackground.CenterLeft),
                 AreaRectangle = new TE_Rectangle(0, 0, 6, size.Y - 12)
             });

             stitchContainer.AddChildren(new RepeatingImage
             {
                 PositionGridBound = new TE_Vector2(size.X - 6, 6),
                 Sprite = SpriteSheetBackground.GetSprite(SpriteSheetBackground.StitchBackground.CenterRight),
                 AreaRectangle = new TE_Rectangle(0, 0, 6, size.Y - 12)
             });

             stitchContainer.AddChildren(new RepeatingImage
             {
                 PositionGridBound = new TE_Vector2(6, 6),
                 Sprite = SpriteSheetBackground.GetSprite(SpriteSheetBackground.StitchBackground.CenterMiddle),
                 AreaRectangle = new TE_Rectangle(0, 0, size.X - 12, size.Y - 12)
             });

             AddChildren(stitchContainer);
         }
    }
}